/**
 * Multicast project Bidois Morgan & Thomas Nunes
 *
 */
package middleware;

import Engine.TypeMessage;

/**
 *
 * @author thomas
 */
public class BurstManager extends Thread {
    
    public void setAlive(boolean alive) {
        this.alive = alive;
    }
    private ClientMulticast multicast;
    private boolean alive = true;
    private int nbMess = 1;
    
    public BurstManager(ClientMulticast papa) {
        multicast = papa;
    }
    
    public void kill() {
        this.setAlive(false);
    }

    @Override
    public void run() {
        while (alive) {
            try {
                Thread.sleep(30);
            } catch (InterruptedException ex) {
                System.out.println("sleep exception.");
            }
            nbMess++;
            this.multicast.sendMsg2All(("[BURST]" + nbMess + " eme message").getBytes(), TypeMessage.NORMAL);
        }
    }
}
